/**
 * 
 */
package net.yters.model.agents.actuators;

import java.util.ArrayList;

import net.yters.util.Box;
import net.yters.util.Util;

public class MoveActuator extends ActuatorAgent {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8722585622106389491L;
	Box f_speed = new Box(new Double(1));
	
	public MoveActuator(Double speed) {
		super();
		f_speed.f_value = speed;
		addBoxedParameter("speed", f_speed);
	}
	
	@Override
	public void execute() {
        ArrayList<Double> newPos = new ArrayList<Double>(Util.add(
        		net.yters.util.Util.disemBoxArray(f_ownerAgent.f_position), 
        		Util.mult(net.yters.util.Util.disemBoxArray(f_ownerAgent.f_direction), (Double) f_speed.f_value)));

        if(f_ownerAgent.f_model.f_env.getContent(newPos) == 0) {
			net.yters.util.Util.emboxArray(f_ownerAgent.f_position, newPos);
		} 
    }
}